/*
 * MySql 配置文件
 */
const mysql = require('mysql');

//创建mysql连接池
const pool = mysql.createPool({
    connectionLimit: 20,//最大连接数
    host: "115.159.118.104",//服务器地址
    port: "3306",//mysql端口
    user: 'han',
    password: 'han631308',
    database: 'react'
});

//接收sql对象
const mysqlConnect = {};

//执行
mysqlConnect.sql = (query, callback) => {
    if (!query) {
        callback();
        return;
    }
    pool.query(query, (err, rows, fields) => {
        if (err) {
            callback(err, null);
        }
        callback(null, rows, fields);
    });
};

module.exports = mysqlConnect;